package com.zhuiyun.project.api.imagesorting.mapper;

import com.zhuiyun.project.api.imagesorting.entity.ImageSorting;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName imageSortingMapper
 * @Description TODO
 * @Author zsc
 * @Date 2024/11/11 19:09
 */
public interface ImageSortingMapper {

    /**
    * @Author zsc
    * @Description 新增图片排序
    * @Date 2024/11/11 19:31
    * @Return int
    * @param imageSorting
    */
    @Insert("INSERT INTO image_sorting (id, sorting, img_id) VALUES (#{id}, #{sorting}, #{imgId})")
    int saveImageSorting(ImageSorting imageSorting);

    /**
    * @Author zsc
    * @Description 删除图片排序
    * @Date 2024/11/11 19:40
    * @Return int
    * @param id
    */
    @Delete("DELETE FROM image_sorting WHERE id = #{id}")
    int deleteImageSorting(@Param("id") int id);

    /**
    * @Author zsc
    * @Description 修改图片排序
    * @Date 2024/11/11 19:49
    * @Return int
    * @param imageSorting
    */
    @Update("UPDATE image_sorting SET sorting = #{sorting}, img_id = #{imgId} WHERE id = #{id}")
    int updateImageSorting(ImageSorting imageSorting);

    /**
    * @Author zsc
    * @Description 查询图片排序
    * @Date 2024/11/11 19:55
    * @Return java.util.List<com.zhuiyun.project.api.imagesorting.entity.ImageSorting>

    */
    @Select("SELECT * FROM image_sorting ORDER BY sorting ASC")
    List<ImageSorting> getImageSortingList();
}
